package io.github.l86400.component.selenium.core.web.driver.manager;

import io.github.l86400.component.selenium.core.web.driver.WebDriver;
import io.github.l86400.util.bean.EmptyUtil;

/**
 * @author 86400
 * @since 2021/12/21 9:40
 */
public abstract class AbstractMemoryWebDriverManager<T extends WebDriver> implements WebDriverManager {
    public abstract T doGet();

    private T webDriver;

    @Override
    public T get() {
        if (EmptyUtil.isEmpty(webDriver)) {
            synchronized (this) {
                if (EmptyUtil.isEmpty(webDriver)) {
                    T t = doGet();
                    this.webDriver = t;
                }
            }
        }
        return this.webDriver;
    }
}
